<?php
/**
 * Tool SLS_HttpRequest - Http Request Treatment
 * 
 * @author Laurent Bientz
 * @author Florian Collot
 * @copyright SillySmart
 * @package Sls.Generics.View
 * @since 1.0  
 */
class SLS_View
{
	private $_generic;
	private $_xml;	
	
	/**
	 * Constructor
	 *
	 * @access public
	 * @param SLS_Generic $generic SLS_Generic instance
	 * @param string $xml xml string to parse
	 * @since 1.0
	 */
	public function __construct($generic,$xml)
	{
		$this->_generic = $generic;		
		$this->_xml = $xml;		
		$this->parseToXhtml();
		
		$this->_generic->logTime($this->_generic->monitor($this->_generic->_time_start),"Process finished","","Render");
	}
	
	/**
	 * Parsing: flow XML + XSL => xHTML
	 *
	 * @access private
	 * @since 1.0
	 */
	private function parseToXhtml()
	{
		$this->_generic->_time_checkpoint = microtime(true);
		
		// Xml
		$xmlDoc = new DOMDocument();		
		try 
		{ 
			$xmlDoc->loadXML($this->_xml); 
		}
		catch (Exception $e)
		{
			SLS_Tracing::addTrace(new Exception("Error during XML Parsing"), true, "<h2>".$e->getMessage()."</h2><div style=\"margin: 0 30px;padding: 10px;\"><pre name=\"code\" class=\"xml\">".htmlentities($this->_xml, ENT_QUOTES)."</pre></div><script language=\"javascript\">dp.SyntaxHighlighter.ClipboardSwf = 'Sls/Scripts/Javascript/Statics/clipboard.swf';dp.SyntaxHighlighter.HighlightAll('code');</script>");
		}
		
		// Xsl
		$xslDoc = new DOMDocument();		
		try 
		{
			$xslDoc->loadXML($this->constructGenericXsl()); 
		}
		catch (Exception $e)
		{
			SLS_Tracing::addTrace(new Exception($e->getMessage()));
		}
		
		// Parsing
		$proc = new XSLTProcessor();
		$proc->registerPHPFunctions();
		try 
		{ 
			$proc->importStyleSheet($xslDoc); 
		}
		catch (Exception $e)
		{
			SLS_Tracing::addTrace(new Exception($e->getMessage()));			
		}
		
		// If errors in dev
		if (!SLS_Generic::getInstance()->isProd() && SLS_Tracing::$_exceptionThrown)
			SLS_Tracing::displayTraces();
		else
		{
			// Show xml in source in dev
			/*if ($this->_generic->getSiteConfig("isProd") == 0)							
				echo "<!--[if lt IE 5]><!--<![CDATA[<pre style='display:none;'>\n".$this->_xml." \n</pre>]]>--><![endif]-->\n";*/
			
			// Parse XML/XSL
			$html = $proc->transformToXML($xmlDoc);			
			$this->_generic->logTime($this->_generic->monitor($this->_generic->_time_checkpoint),"Parsing XML/XSL","","XML/XSL Parsing");
			$this->_generic->_time_checkpoint = microtime(true);
			
			// Parse HTML with SLS_Dtd
			echo $this->parseHtml($html);
			$this->_generic->logTime($this->_generic->monitor($this->_generic->_time_checkpoint),"Parsing HTML","","HTML Parsing");
			
			// Show flash button to copy Xml in dev
			if ($this->_generic->getSiteConfig("isProd") == 0 && $this->_generic->getSide() == "user" && $this->_generic->getObjectHttpRequest()->getParam("SlsQuick") != "iFrame" /*&& $this->_generic->getGenericControllerName() != array_shift($this->_generic->getControllersXML()->getTags("//controllers/controller[@isBo='true']/@name"))*/)
			{				
				echo '<script type="text/javascript">var sls_dynamic_xml = document.createElement("pre");sls_dynamic_xml.setAttribute("id","sls_xml_source");sls_dynamic_xml.setAttribute("style","display:none");sls_dynamic_xml.innerHTML = "'.htmlentities(str_replace(array('"',"\n"),array('\"',''),$this->_xml),ENT_COMPAT,"UTF-8").'";document.getElementById("SLS_DevelopperToolbar").getElementsByTagName("ul")[0].appendChild(sls_dynamic_xml);var sls_dynamic_dev = document.createElement("li");sls_dynamic_dev.setAttribute("id","sls_xml_button");sls_dynamic_dev.setAttribute("title","Copy XML to Clipboard");sls_dynamic_dev.setAttribute("class","section");document.createElement("li");document.getElementById("SLS_DevelopperToolbar").getElementsByTagName("ul")[0].appendChild(sls_dynamic_dev);sls_dynamic_dev.innerHTML = "<span class=\"section\">XML</span>";</script><script type="text/javascript" src="http://'.$this->_generic->getSiteConfig("domainName")."/".$this->_generic->getPathConfig("coreJsStatics").'ZeroClipboard.js"></script><script type="text/javascript">ZeroClipboard.setMoviePath("http://'.$this->_generic->getSiteConfig("domainName")."/".$this->_generic->getPathConfig("coreJsStatics").'ZeroClipboard.swf");var clip = new ZeroClipboard.Client();clip.setHandCursor(true);clip.setText(html_entity_decode(document.getElementById("sls_xml_source").innerHTML));clip.glue(document.getElementById("sls_xml_button"), document.getElementById("sls_xml_button"));function html_entity_decode (string, quote_style) {var hash_map = {}, symbol = \'\', tmp_str = \'\', entity = \'\';tmp_str = string.toString();if (false === (hash_map = this.get_html_translation_table(\'HTML_ENTITIES\', quote_style))) { return false; }hash_map[\'&\'] = \'&amp;\';for (symbol in hash_map) {entity = hash_map[symbol]; tmp_str = tmp_str.split(entity).join(symbol);}tmp_str = tmp_str.split(\'&#039;\').join("\'");return tmp_str;}function get_html_translation_table (table, quote_style) {var entities = {}, hash_map = {}, decimal = 0, symbol = \'\'; var constMappingTable = {}, constMappingQuoteStyle = {};var useTable = {}, useQuoteStyle = {};constMappingTable[0] = \'HTML_SPECIALCHARS\'; constMappingTable[1] = \'HTML_ENTITIES\';constMappingQuoteStyle[0] = \'ENT_NOQUOTES\';constMappingQuoteStyle[2] = \'ENT_COMPAT\';constMappingQuoteStyle[3] = \'ENT_QUOTES\';useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : \'HTML_SPECIALCHARS\';useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : \'ENT_COMPAT\';if (useTable !== \'HTML_SPECIALCHARS\' && useTable !== \'HTML_ENTITIES\') {throw new Error("Table: "+useTable+\' not supported\');}entities[\'38\'] = \'&amp;\';if (useTable === \'HTML_ENTITIES\') {entities[\'160\'] = \'&nbsp;\';entities[\'161\'] = \'&iexcl;\'; entities[\'162\'] = \'&cent;\'; entities[\'163\'] = \'&pound;\'; entities[\'164\'] = \'&curren;\'; entities[\'165\'] = \'&yen;\'; entities[\'166\'] = \'&brvbar;\'; entities[\'167\'] = \'&sect;\'; entities[\'168\'] = \'&uml;\'; entities[\'169\'] = \'&copy;\'; entities[\'170\'] = \'&ordf;\'; entities[\'171\'] = \'&laquo;\'; entities[\'172\'] = \'&not;\'; entities[\'173\'] = \'&shy;\'; entities[\'174\'] = \'&reg;\'; entities[\'175\'] = \'&macr;\'; entities[\'176\'] = \'&deg;\'; entities[\'177\'] = \'&plusmn;\'; entities[\'178\'] = \'&sup2;\'; entities[\'179\'] = \'&sup3;\'; entities[\'180\'] = \'&acute;\'; entities[\'181\'] = \'&micro;\'; entities[\'182\'] = \'&para;\'; entities[\'183\'] = \'&middot;\'; entities[\'184\'] = \'&cedil;\'; entities[\'185\'] = \'&sup1;\'; entities[\'186\'] = \'&ordm;\'; entities[\'187\'] = \'&raquo;\'; entities[\'188\'] = \'&frac14;\'; entities[\'189\'] = \'&frac12;\'; entities[\'190\'] = \'&frac34;\'; entities[\'191\'] = \'&iquest;\'; entities[\'192\'] = \'&Agrave;\'; entities[\'193\'] = \'&Aacute;\'; entities[\'194\'] = \'&Acirc;\'; entities[\'195\'] = \'&Atilde;\'; entities[\'196\'] = \'&Auml;\'; entities[\'197\'] = \'&Aring;\'; entities[\'198\'] = \'&AElig;\'; entities[\'199\'] = \'&Ccedil;\'; entities[\'200\'] = \'&Egrave;\'; entities[\'201\'] = \'&Eacute;\'; entities[\'202\'] = \'&Ecirc;\'; entities[\'203\'] = \'&Euml;\'; entities[\'204\'] = \'&Igrave;\'; entities[\'205\'] = \'&Iacute;\'; entities[\'206\'] = \'&Icirc;\'; entities[\'207\'] = \'&Iuml;\'; entities[\'208\'] = \'&ETH;\'; entities[\'209\'] = \'&Ntilde;\'; entities[\'210\'] = \'&Ograve;\'; entities[\'211\'] = \'&Oacute;\'; entities[\'212\'] = \'&Ocirc;\'; entities[\'213\'] = \'&Otilde;\'; entities[\'214\'] = \'&Ouml;\'; entities[\'215\'] = \'&times;\'; entities[\'216\'] = \'&Oslash;\'; entities[\'217\'] = \'&Ugrave;\'; entities[\'218\'] = \'&Uacute;\'; entities[\'219\'] = \'&Ucirc;\'; entities[\'220\'] = \'&Uuml;\'; entities[\'221\'] = \'&Yacute;\'; entities[\'222\'] = \'&THORN;\'; entities[\'223\'] = \'&szlig;\'; entities[\'224\'] = \'&agrave;\'; entities[\'225\'] = \'&aacute;\'; entities[\'226\'] = \'&acirc;\'; entities[\'227\'] = \'&atilde;\'; entities[\'228\'] = \'&auml;\'; entities[\'229\'] = \'&aring;\'; entities[\'230\'] = \'&aelig;\'; entities[\'231\'] = \'&ccedil;\'; entities[\'232\'] = \'&egrave;\'; entities[\'233\'] = \'&eacute;\'; entities[\'234\'] = \'&ecirc;\'; entities[\'235\'] = \'&euml;\'; entities[\'236\'] = \'&igrave;\'; entities[\'237\'] = \'&iacute;\'; entities[\'238\'] = \'&icirc;\'; entities[\'239\'] = \'&iuml;\'; entities[\'240\'] = \'&eth;\'; entities[\'241\'] = \'&ntilde;\'; entities[\'242\'] = \'&ograve;\'; entities[\'243\'] = \'&oacute;\'; entities[\'244\'] = \'&ocirc;\'; entities[\'245\'] = \'&otilde;\'; entities[\'246\'] = \'&ouml;\'; entities[\'247\'] = \'&divide;\'; entities[\'248\'] = \'&oslash;\'; entities[\'249\'] = \'&ugrave;\'; entities[\'250\'] = \'&uacute;\'; entities[\'251\'] = \'&ucirc;\'; entities[\'252\'] = \'&uuml;\'; entities[\'253\'] = \'&yacute;\'; entities[\'254\'] = \'&thorn;\'; entities[\'255\'] = \'&yuml;\';}if (useQuoteStyle !== \'ENT_NOQUOTES\') {entities[\'34\'] = \'&quot;\';}if (useQuoteStyle === \'ENT_QUOTES\'){entities[\'39\'] = \'&#39;\';}entities[\'60\'] = \'&lt;\';entities[\'62\'] = \'&gt;\';for (decimal in entities){symbol = String.fromCharCode(decimal);hash_map[symbol] = entities[decimal];}return hash_map;}</script>';
				// Uncompressed script
				/*echo '<script type="text/javascript">
						var sls_dynamic_xml = document.createElement("pre");						
						sls_dynamic_xml.setAttribute("id","sls_xml_source");
						sls_dynamic_xml.setAttribute("style","display:none");
						sls_dynamic_xml.innerHTML = "'.htmlentities(str_replace(array('"',"\n"),array('\"',''),$this->_xml),ENT_COMPAT,"UTF-8").'";						
						document.getElementsByTagName("body")[0].appendChild(sls_dynamic_xml);						
						var sls_dynamic_dev = document.createElement("div");
						sls_dynamic_dev.setAttribute("id","sls_xml_button");
						sls_dynamic_dev.setAttribute("style","position:fixed;top:0;right:0;background-color:#837FD5;color:#b7b7b7;width:220px;height:30px;font-family:Arial;font-size:14px;border:2px solid #5B598F");					
						sls_dynamic_dev.innerHTML = "<img src=\"http://'.$this->_generic->getSiteConfig("domainName")."/".$this->_generic->getPathConfig("coreLogos").'smallBrain.png\" height=\"30\" align=\"absmiddle\" alt=\"\" /> SLS Dev - XML to Clipboard";
						document.getElementsByTagName("body")[0].appendChild(sls_dynamic_dev);
					</script>
					<script type="text/javascript" src="http://'.$this->_generic->getSiteConfig("domainName")."/".$this->_generic->getPathConfig("coreJsStatics").'ZeroClipboard.js"></script>
					<script type="text/javascript">					
						ZeroClipboard.setMoviePath("http://'.$this->_generic->getSiteConfig("domainName")."/".$this->_generic->getPathConfig("coreJsStatics").'ZeroClipboard.swf");
						var clip = new ZeroClipboard.Client();
						clip.setHandCursor(true);
						clip.setText(html_entity_decode(document.getElementById("sls_xml_source").innerHTML));						
						clip.glue("sls_xml_button");
						function html_entity_decode (string, quote_style) {
						    var hash_map = {}, symbol = \'\', tmp_str = \'\', entity = \'\';
						    tmp_str = string.toString();						    
						    if (false === (hash_map = this.get_html_translation_table(\'HTML_ENTITIES\', quote_style))) { return false; }								
						    hash_map[\'&\'] = \'&amp;\';						 
						    for (symbol in hash_map) {
						        entity = hash_map[symbol]; tmp_str = tmp_str.split(entity).join(symbol);
						    }
						    tmp_str = tmp_str.split(\'&#039;\').join("\'");						    
						    return tmp_str;
						}
						function get_html_translation_table (table, quote_style) {    
						    var entities = {}, hash_map = {}, decimal = 0, symbol = \'\';
						    var constMappingTable = {}, constMappingQuoteStyle = {};
						    var useTable = {}, useQuoteStyle = {};						        
						    constMappingTable[0] = \'HTML_SPECIALCHARS\';
						    constMappingTable[1] = \'HTML_ENTITIES\';
						    constMappingQuoteStyle[0] = \'ENT_NOQUOTES\';
						    constMappingQuoteStyle[2] = \'ENT_COMPAT\';
						    constMappingQuoteStyle[3] = \'ENT_QUOTES\';
						    useTable = !isNaN(table) ? constMappingTable[table] : table ? table.toUpperCase() : \'HTML_SPECIALCHARS\';
						    useQuoteStyle = !isNaN(quote_style) ? constMappingQuoteStyle[quote_style] : quote_style ? quote_style.toUpperCase() : \'ENT_COMPAT\';						 
						    if (useTable !== \'HTML_SPECIALCHARS\' && useTable !== \'HTML_ENTITIES\') {
						        throw new Error("Table: "+useTable+\' not supported\');
						    }						 
						    entities[\'38\'] = \'&amp;\';
						    if (useTable === \'HTML_ENTITIES\') {entities[\'160\'] = \'&nbsp;\';
								entities[\'161\'] = \'&iexcl;\';
								entities[\'162\'] = \'&cent;\';
								entities[\'163\'] = \'&pound;\';
								entities[\'164\'] = \'&curren;\';entities[\'165\'] = \'&yen;\';
								entities[\'166\'] = \'&brvbar;\';
								entities[\'167\'] = \'&sect;\';
								entities[\'168\'] = \'&uml;\';
								entities[\'169\'] = \'&copy;\';entities[\'170\'] = \'&ordf;\';
								entities[\'171\'] = \'&laquo;\';
								entities[\'172\'] = \'&not;\';
								entities[\'173\'] = \'&shy;\';
								entities[\'174\'] = \'&reg;\';entities[\'175\'] = \'&macr;\';
								entities[\'176\'] = \'&deg;\';
								entities[\'177\'] = \'&plusmn;\';
								entities[\'178\'] = \'&sup2;\';
								entities[\'179\'] = \'&sup3;\';entities[\'180\'] = \'&acute;\';
								entities[\'181\'] = \'&micro;\';
								entities[\'182\'] = \'&para;\';
								entities[\'183\'] = \'&middot;\';
								entities[\'184\'] = \'&cedil;\';entities[\'185\'] = \'&sup1;\';
								entities[\'186\'] = \'&ordm;\';
								entities[\'187\'] = \'&raquo;\';
								entities[\'188\'] = \'&frac14;\';
								entities[\'189\'] = \'&frac12;\';entities[\'190\'] = \'&frac34;\';
								entities[\'191\'] = \'&iquest;\';
								entities[\'192\'] = \'&Agrave;\';
								entities[\'193\'] = \'&Aacute;\';
								entities[\'194\'] = \'&Acirc;\';entities[\'195\'] = \'&Atilde;\';
								entities[\'196\'] = \'&Auml;\';
								entities[\'197\'] = \'&Aring;\';
								entities[\'198\'] = \'&AElig;\';
								entities[\'199\'] = \'&Ccedil;\';entities[\'200\'] = \'&Egrave;\';
								entities[\'201\'] = \'&Eacute;\';
								entities[\'202\'] = \'&Ecirc;\';
								entities[\'203\'] = \'&Euml;\';
								entities[\'204\'] = \'&Igrave;\';entities[\'205\'] = \'&Iacute;\';
								entities[\'206\'] = \'&Icirc;\';
								entities[\'207\'] = \'&Iuml;\';
								entities[\'208\'] = \'&ETH;\';
								entities[\'209\'] = \'&Ntilde;\';entities[\'210\'] = \'&Ograve;\';
								entities[\'211\'] = \'&Oacute;\';
								entities[\'212\'] = \'&Ocirc;\';
								entities[\'213\'] = \'&Otilde;\';
								entities[\'214\'] = \'&Ouml;\';entities[\'215\'] = \'&times;\';
								entities[\'216\'] = \'&Oslash;\';
								entities[\'217\'] = \'&Ugrave;\';
								entities[\'218\'] = \'&Uacute;\';
								entities[\'219\'] = \'&Ucirc;\';entities[\'220\'] = \'&Uuml;\';
								entities[\'221\'] = \'&Yacute;\';
								entities[\'222\'] = \'&THORN;\';
								entities[\'223\'] = \'&szlig;\';
								entities[\'224\'] = \'&agrave;\';entities[\'225\'] = \'&aacute;\';
								entities[\'226\'] = \'&acirc;\';
								entities[\'227\'] = \'&atilde;\';
								entities[\'228\'] = \'&auml;\';
								entities[\'229\'] = \'&aring;\';entities[\'230\'] = \'&aelig;\';
								entities[\'231\'] = \'&ccedil;\';
								entities[\'232\'] = \'&egrave;\';
								entities[\'233\'] = \'&eacute;\';
								entities[\'234\'] = \'&ecirc;\';entities[\'235\'] = \'&euml;\';
								entities[\'236\'] = \'&igrave;\';
								entities[\'237\'] = \'&iacute;\';
								entities[\'238\'] = \'&icirc;\';
								entities[\'239\'] = \'&iuml;\';entities[\'240\'] = \'&eth;\';
								entities[\'241\'] = \'&ntilde;\';
								entities[\'242\'] = \'&ograve;\';
								entities[\'243\'] = \'&oacute;\';
								entities[\'244\'] = \'&ocirc;\';entities[\'245\'] = \'&otilde;\';
								entities[\'246\'] = \'&ouml;\';
								entities[\'247\'] = \'&divide;\';
								entities[\'248\'] = \'&oslash;\';
								entities[\'249\'] = \'&ugrave;\';entities[\'250\'] = \'&uacute;\';
								entities[\'251\'] = \'&ucirc;\';
								entities[\'252\'] = \'&uuml;\';
								entities[\'253\'] = \'&yacute;\';
								entities[\'254\'] = \'&thorn;\';entities[\'255\'] = \'&yuml;\';
						    }						 
						    if (useQuoteStyle !== \'ENT_NOQUOTES\') {
								entities[\'34\'] = \'&quot;\';    }
						    if (useQuoteStyle === \'ENT_QUOTES\') {
								entities[\'39\'] = \'&#39;\';
						    }
						    entities[\'60\'] = \'&lt;\';entities[\'62\'] = \'&gt;\';								
						    for (decimal in entities) {
						    	symbol = String.fromCharCode(decimal);
						        hash_map[symbol] = entities[decimal];
						    }			    
						    return hash_map;
						}
					</script>
					';*/	
			}
		}		
	}
	
	/**
	 * Construct generic XML
	 *
	 * @access public	 
	 * @return string $xsl the xsl content
	 * @since 1.0
	 */
	public function constructGenericXsl()
	{		
		if ($this->_generic->getSide() == 'user')		
			$xsl = file_get_contents($this->_generic->getPathConfig("viewsTemplates").$this->_generic->getCurrentTpl().".xsl");		
		else			
			$xsl = file_get_contents($this->_generic->getPathConfig("coreViewsTemplates").$this->_generic->getCurrentTpl().".xsl");
					
		$delimiters = SLS_String::getBoundContent($xsl,"|||sls:","|||");
		$arraySearch = array();
		$arrayReplace = array();
		
		$dtd = new SLS_Dtd($this->_xml);
		
		// Foreach delimiters found, search if we can map a function of SLS_Dtd's class with this delimiter
		foreach($delimiters as $delimiter)
		{
			$dtd_mask = $delimiter;
			$delimiter = explode(":",$delimiter);
			$method = array_shift($delimiter);
			$args = $delimiter;			
						
			$ref = new ReflectionMethod($dtd,$method);			
			$nbRequiredParams = $ref->getNumberOfRequiredParameters();
			$nbMaxParams = $ref->getNumberOfParameters();			
			if ($nbRequiredParams > count($args))			
				SLS_Tracing::addTrace(new Exception("Error: Specific SLS_Dtd function `".$method."` needs at least ".$nbRequiredParams." required parameters"),true);				
			if ($nbMaxParams < count($args))
				SLS_Tracing::addTrace(new Exception("Warning: Specific SLS_Dtd function `".$method."` has only ".$nbMaxParams." parameters, you call it with ".count($args)." parameters"),true);
			
			if (method_exists($dtd,$method))
			{
				array_push($arraySearch,"|||sls:".$dtd_mask."|||");
				array_push($arrayReplace,$ref->invokeArgs($dtd,$args));
			}
			else
				SLS_Tracing::addTrace(new Exception("Warning: the delimiter |||sls:".$delimiter."||| doesn't match with any function of class SLS_Dtd"));
		}
		return str_replace($arraySearch,$arrayReplace,$xsl);
	}
	
	/**
	 * Parse final HTML with SLS_Dtd
	 * 
	 * @access public
	 * @param string $html the HTML content
	 * @return string the HTML content parsed
	 * @since 1.0.8
	 */
	public function parseHtml($html)
	{
		$delimiters = SLS_String::getBoundContent($html,"|||sls:","|||");
		$arraySearch = array();
		$arrayReplace = array();
		
		$dtd = new SLS_Dtd(null);
		
		// Foreach delimiters found, search if we can map a function of SLS_Dtd's class with this delimiter
		foreach($delimiters as $delimiter)
		{
			$dtd_mask = $delimiter;
			$delimiter = explode(":",$delimiter);
			$method = array_shift($delimiter);
			$args = $delimiter;			
			
			$ref = new ReflectionMethod($dtd,$method);			
			$nbRequiredParams = $ref->getNumberOfRequiredParameters();
			$nbMaxParams = $ref->getNumberOfParameters();
			
			if ($nbRequiredParams > count($args))			
				SLS_Tracing::addTrace(new Exception("Error: Specific SLS_Dtd function `".$method."` needs at least ".$nbRequiredParams." required parameters"),true);
			if ($nbMaxParams < count($args))
				SLS_Tracing::addTrace(new Exception("Warning: Specific SLS_Dtd function `".$method."` has only ".$nbMaxParams." parameters, you call it with ".count($args)." parameters"),true);
			
			if (method_exists($dtd,$method) && $nbRequiredParams <= count($args))
			{
				array_push($arraySearch,"|||sls:".$dtd_mask."|||");
				array_push($arrayReplace,$ref->invokeArgs($dtd,$args));
			}
			else
				SLS_Tracing::addTrace(new Exception("Warning: the delimiter |||sls:".$method."||| doesn't match with any function of class SLS_Dtd"));
		}
		return str_replace($arraySearch,$arrayReplace,$html);
	}
}
?>